
/**
 * 
 * @param {Array} menulist 用户的菜单信息，用于和allRoutes进行对比
 * @param {Array} allRoutes 用户的完整动态路由表
 */

let recursionRoutes = (menulist,allRoutes=[]) => {
    // 用于放置对比之后的路由数据
    let userRoutes = [];

    menulist.length>0 && menulist.forEach(menu => {

        allRoutes.forEach(route=>{
            if(menu.title===route.meta.title){

                if(menu.children && menu.children.length>0){
                    // 如果有children属性，需要递归重新计算
                    route.children = recursionRoutes(menu.children,route.children)
                }

                userRoutes.push(route)
            }
        })
    })
    return userRoutes
}
export default recursionRoutes